package com.kantboot.business.common.dao.i18n.repository;

import com.kantboot.business.common.domain.i18n.BusCommonCarouselImageI18n;
import jakarta.transaction.Transactional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface BusCommonCarouselImageI18nRepository extends JpaRepository<BusCommonCarouselImageI18n,Long> {

    /**
     * 根据轮播图id查询轮播图国际化信息
     */
    List<BusCommonCarouselImageI18n> getByCarouselImageId(Long carouselImageId);

    /**
     * 根据语言编码和轮播图id查询轮播图国际化信息
     */
    BusCommonCarouselImageI18n getByLanguageCodeAndCarouselImageId(String languageCode, Long carouselImageId);

    /**
     * 根据语言编码获取轮播图
     */
    List<BusCommonCarouselImageI18n> getByLanguageCode(String languageCode);

    /**
     * 根据语言编码和轮播图id删除轮播图国际化图片
     */
    @Modifying
    @Transactional
    @Query("update BusCommonCarouselImageI18n set fileIdOfImage = null where languageCode = ?1 and carouselImageId = ?2")
    void clearFileIdOfImageByLanguageCodeAndCarouselImageId(String languageCode, Long carouselImageId);

}
